﻿Ext.override(NExt.Demo.Application.Entity.Bind.FindReference, {
    templateClose: function() {
        this.containerWindow.close();
    },

    templateShow: function() {

        this.containerWindow = new Ext.Window({
            modal: true,
            items: this
        });

        this.containerWindow.show();
    },

    setCurrentModel: function(current) {
        if (!current) {
            return;
        }

        var currentRecord;
        this.browsePresenter.store.each(function(record) {
            if (record.get('Name') == current.Name) {
                currentRecord = record;
                return false;
            }
        });

        var selectionModel = this.browsePresenter.gridPanel.getSelectionModel();
        selectionModel.selectRecords.defer(200, selectionModel, [[currentRecord]]);
    }
});
